package com.weixin.engine.design.chain;

/**
 * 发送请求到OpenAPI接口并获取响应的处理程序
 *
 * @author wangchunhui
 * @date 2023/7/20 10:06
 */
public class ApiCallHandler implements Handler {
    private Handler nextHandler;

    @Override
    public void setNext(Handler handler) {
        this.nextHandler = handler;
    }

    @Override
    public void handleRequest(Request request) {
        Response response = sendApiRequest(request);
        if (nextHandler != null) {
            nextHandler.handleResponse(response);
        }
    }

    @Override
    public void handleResponse(Response response) {

    }

    private Response sendApiRequest(Request request) {
        // 在此处发送API请求并获取响应
        Response response = new Response();
        response.setData("API response");
        return response;
    }
}